package cj.web.marriage.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.marriage.domain.CmpActivity;

/**
 * 
 * @author 
 *
 */
@DAO
public interface CmpActivityDAO{
	
	@SQL("SELECT * FROM CmpActivity WHERE deleteFlag=1 #if(:t.name!=''){ AND name like '%##(:t.name)%'} ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<CmpActivity> query(@SQLParam("t") CmpActivity cmpActivity);
		
	@SQL("SELECT count(1) FROM CmpActivity WHERE deleteFlag=1 #if(:t.name!=''){ AND name like '%##(:t.name)%'} " )
    int querySize(@SQLParam("t") CmpActivity cmpActivity);
    
    @SQL("select * from CmpActivity where id=:1")
    CmpActivity queryById(int id);
    
    @SQL("INSERT INTO CmpActivity ("
			        		+ "img,"
			        		+ "type,"
			        		+ "name,"
			        		+ "descs,"
			        		+ "price,"
			        		+ "duration,"
			        		+ "count,"
			        		+ "orderNo,"
			        		+ "startDate,"
			        		+ "endDate,"
			        		+ "deleteFlag,"
			        		+ "createUser,"
			        		+ "createAt,"
			        		+ "updateUser,"
			        		+ "updateAt"
							+") VALUES ("
							+ ":t.img,"
							+ ":t.type,"
							+ ":t.name,"
							+ ":t.descs,"
							+ ":t.price,"
							+ ":t.duration,"
							+ "0,"
							+ ":t.orderNo,"
							+ ":t.startDate,"
							+ ":t.endDate,"
							+ "1,"
							+ ":t.createUser,"
							+ "now(),"
							+ ":t.updateUser,"
							+ "now()"
					+")")
    void create(@SQLParam("t") CmpActivity cmpActivity);
	
	@SQL("UPDATE CmpActivity SET "
	    			        + "img=:t.img,"
	    			        + "type=:t.type,"
	    			        + "name=:t.name,"
	    			        + "descs=:t.descs,"
	    			        + "price=:t.price,"
	    			        + "duration=:t.duration,"
	    			        + "orderNo=:t.orderNo,"
	    			        + "startDate=:t.startDate,"
	    			        + "endDate=:t.endDate,"
	    			        + "updateUser=:t.updateUser,"
	    			        + "updateAt=now()"
    						+ " WHERE id=:t.id")
    void update(@SQLParam("t") CmpActivity cmpActivity);
    
    @SQL("UPDATE CmpActivity SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
}